using System.Collections;
using System.Collections.Generic;
using UnityEngine;


namespace Ants.Utilities
{
    /**
     * 追求效率但不见得精确的数学库(目标精度至少在两位小数)
     */
    public class Math
    {
        /**
         * 两向量夹角余弦的平方
         */
        public static float SqrCosineOf(Vector2 a, Vector2 b)
        {
            float sqr = Vector2.Dot(a, b);
            sqr *= sqr;
            return sqr / (Vector2.Dot(a, a) * Vector2.Dot(b, b));
        }

        public static bool EqualsZero(float a,float tolerance=Const.EPS)
        {
            return Mathf.Abs(a) < tolerance;
        }

        public static bool PointMatch(Vector2 a, Vector2 b,float tolerance=Const.EPS)
        {
            a = a - b;
            return EqualsZero(Vector2.Dot(a, a),tolerance);
        }
    }

}
